package m1.server.config.connector;

import m1.server.config.connector.glue.SecurityRequestGlue;
import m1.server.config.connector.role.ReceiveRequestorSecurityManagement;
import m1.server.config.connector.role.RequestorSecurityManagement;
import m1.server.config.connector.role.Security;
import m1.server.config.connector.role.SendSecurity;
import m2.connector.Connector;

public class SecurityRequest extends Connector{
	
	private static SecurityRequest securityRequest = null;
	
	private SecurityRequest(){
		addGlueIn(new SecurityRequestGlue());
		addGlueOut(new SecurityRequestGlue());
		
		ReceiveRequestorSecurityManagement receiveRequestorSecurityManagement = new ReceiveRequestorSecurityManagement();
		Security security = new Security();
		RequestorSecurityManagement requestorSecurityManagement = new RequestorSecurityManagement();
		SendSecurity sendSecurity = new SendSecurity();
		
		addRequiredRole(receiveRequestorSecurityManagement, security);
		addProvidedRole(requestorSecurityManagement, sendSecurity);
		
		((SecurityRequestGlue)getGlueIn()).securityRequestConnectRequiredRoleToProvidedRole(security, requestorSecurityManagement);
		((SecurityRequestGlue)getGlueOut()).securityRequestConnectProvidedRoleToRequiredRole(sendSecurity, receiveRequestorSecurityManagement);
		
	}
	
	/**
	 * 
	 * @return
	 */
	public static SecurityRequest getInstance(){
		if (securityRequest == null){
			securityRequest = new SecurityRequest();
		}
		return securityRequest;
	}
	
}
